package main
import(
	"fmt"
	"time"
)

type query func(string) string

func exec(name string, vs ...query) string {
	ch := make(chan string)
	fn := func(i int) {
		if(0 == i || 1 == i || 3 == i){
			time.Sleep(time.Second * 10)
		}

		ch <- vs[i](name)
	}
	for i, currVs := range vs {
		fmt.Printf("i=%v\n", i)
		fmt.Printf("currVs=%v\n", currVs(""))
		currI := i
		go fn(currI)
	}
	return <-ch
}

func main() {
	ret := exec("111", func(n string) string {
		return n + "func1"
	}, func(n string) string {
		return n + "func2"
	}, func(n string) string {
		return n + "func3"
	}, func(n string) string {
		return n + "func4"
	})
	fmt.Println(ret)

	
	var iTmp int
	fmt.Printf("iTmp=%v\n", iTmp)
}
 